package Com;

import java.util.ArrayList;

public class Plate extends MyElement{
    private ArrayList list = new ArrayList();

    public void add(MyElement element){
        list.add(element);
    }
    public void delete(MyElement element){
        list.remove(element);
    }

    @Override
    public void eat() {
        //遍历 list 中的所有元素，并对每个元素调用其 eat 方法。
        for(Object object:list){
            ((MyElement)object).eat();
        }
    }
}
